package com.example.jiankang.pages;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.example.jiankang.Fragment.ShouyeFragment;
import com.example.jiankang.Fragment.jiluFragment;
import com.example.jiankang.Fragment.wodeFragment;
import com.example.jiankang.R;

public class zhuyemianActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_zhuyemian);
        FragmentManager sy= getSupportFragmentManager();
        FragmentTransaction st = sy.beginTransaction();
        ShouyeFragment s1 = new ShouyeFragment();
        jiluFragment j1 =new jiluFragment();
        wodeFragment w1 = new wodeFragment();
        st.replace(R.id.la_table,s1);
        st.commit();
        LinearLayout l1 = findViewById(R.id.la1);
        LinearLayout l2 = findViewById(R.id.la2);
        LinearLayout l3 = findViewById(R.id.la3);
        TextView shouye = findViewById(R.id.text_shouye);
        TextView jilu = findViewById(R.id.text_jilu);
        TextView wode = findViewById(R.id.text_wode);
        ImageView syimage = findViewById(R.id.image_shouye);
        ImageView jlimage = findViewById(R.id.image_jilu);
        ImageView wdimage = findViewById(R.id.image_wode);


        l1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentManager sy= getSupportFragmentManager();
                FragmentTransaction st = sy.beginTransaction();
                ShouyeFragment s1 = new ShouyeFragment();
                st.replace(R.id.la_table,s1);
                shouye.setTextColor(getResources().getColor(R.color.background));
                jilu.setTextColor(getResources().getColor(R.color.black));
                wode.setTextColor(getResources().getColor(R.color.black));
                syimage.setImageResource(R.drawable.shouye_green);
                jlimage.setImageResource(R.drawable.biji_black);
                wdimage.setImageResource(R.drawable.mine_black);
                st.commit();

            }
        });
        l2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentManager sy= getSupportFragmentManager();
                FragmentTransaction st = sy.beginTransaction();
                jiluFragment j1 =new jiluFragment();
                st.replace(R.id.la_table,j1);
                shouye.setTextColor(getResources().getColor(R.color.black));
                jilu.setTextColor(getResources().getColor(R.color.background));
                wode.setTextColor(getResources().getColor(R.color.black));
                syimage.setImageResource(R.drawable.shouye_black);
                jlimage.setImageResource(R.drawable.biji_green);
                wdimage.setImageResource(R.drawable.mine_black);
                st.commit();

            }
        });
        l3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentManager sy= getSupportFragmentManager();
                FragmentTransaction st = sy.beginTransaction();
                ShouyeFragment s1 = new ShouyeFragment();
                jiluFragment j1 =new jiluFragment();
                wodeFragment w1 = new wodeFragment();
                st.replace(R.id.la_table,w1);
                shouye.setTextColor(getResources().getColor(R.color.black));
                jilu.setTextColor(getResources().getColor(R.color.black));
                wode.setTextColor(getResources().getColor(R.color.background));
                syimage.setImageResource(R.drawable.shouye_black);
                jlimage.setImageResource(R.drawable.biji_black);
                wdimage.setImageResource(R.drawable.mine_green);
                st.commit();

            }
        });


    }
}